package teaching.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mapstruct.Mapper;
import teaching.pojo.Point;
import teaching.pojo.PointRelation;
import teaching.pojo.Student;

import java.util.List;

/**
 * Author:20201002983_郑雨蓓
 * Date: 2024/3/13
 * Description:
 */
@Mapper
public interface PointMapper extends BaseMapper<Point> {
    List<Point> getAllPointsWithQuestions();

    @Select("SELECT * from point_relation where point1_id = #{pointId} OR point2_id = #{pointId}")
    List<PointRelation> findRelatedPoints(@Param("pointId") long pointId);

    int updateCorrelationStrength(@Param("id") long id, @Param("correlationStrength") int correlationStrength);

    @Insert("INSERT INTO point_relation (point1_id, point2_id, correlation_strength) " +
            "VALUES (#{pointRelation.point1Id}, #{pointRelation.point2Id}, #{pointRelation.correlationStrength})")
    int insert(@Param("pointRelation") PointRelation pointRelation);

    @Insert("INSERT INTO point (name, introduction, tag_id) VALUES (#{point.name}, #{point.introduction}, #{point.tagId})")
    int addPoint(@Param("point") Point point);

    @Select("select * from point where tag_id=#{tagId}")
    List<Point> getPointByTag(@Param("tagId") Long tagId);
}
